-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose echo.add() method for dynamic route registration #965
Conversation
Codecov Report
@@ Coverage Diff @@
## master #965 +/- ##
======================================
Coverage 78.2% 78.2%
======================================
Files 27 27
Lines 1831 1831
======================================
Hits 1432 1432
Misses 278 278
Partials 121 121
Continue to review full report at Codecov.
|
echo.go
Outdated
@@ -460,7 +460,7 @@ func (e *Echo) File(path, file string) *Route { | |||
}) | |||
} | |||
|
|||
func (e *Echo) add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route { | |||
func (e *Echo) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a godoc like Any
or similar methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc added.
echo.go
Outdated
@@ -460,7 +460,9 @@ func (e *Echo) File(path, file string) *Route { | |||
}) | |||
} | |||
|
|||
func (e *Echo) add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route { | |||
// Add registers a new route for all HTTP methods and path with matching handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for all methods, it should be "for an HTTP method and path ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my head's not int the game today 😞
Should it be "for an HTTP method..." or "for a HTTP method..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets stick to an.
@nicklaw5 thanks for your contribution 🎉 |
This exposes the
echo.add
(becomesecho.Add
) method which makes it easy to iterate over a map of routes and dynamically register them.For example: